<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="custom-style.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
	<div style="overflow: hidden;">
		<div style="height: 57px;min-width: 1039px;background-size: auto 100%;background:url('');">
			<img src="titleleft.png" style="float: left;"/>
			<img src="titleright.png" alt="" style="float: right;" />
		</div>
	</div>
<!-- 制作者 Doxygen 1.8.15 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>法律声明</span></a></li>
      <li><a href="_xE9_xA6_x96_xE9_xA1_xB5.html"><span>首页</span></a></li>
      <li><a href="_xE6_x9B_xB4_xE6_x96_xB0_xE8_xAE_xB0_xE5_xBD_x95.html"><span>更新记录</span></a></li>
      <li><a href="_xE7_x8E_xAF_xE5_xA2_x83_xE9_x85_x8D_xE7_xBD_xAE.html"><span>环境配置</span></a></li>
      <li><a href="_xE7_xBC_x96_xE7_xA8_x8B_xE5_xBC_x95_xE5_xAF_xBC.html"><span>编程引导</span></a></li>
      <li><a href="modules.html"><span>接口说明</span></a></li>
      <li><a href="annotated.html"><span>结构体定义</span></a></li>
      <li><a href="_xE7_x9B_xB8_xE6_x9C_xBA_xE5_x8F_x82_xE6_x95_xB0_xE8_x8A_x82_xE7_x82_xB9_xE8_xA1_xA8.html"><span>相机参数节点表</span></a></li>
      <li><a href="examples.html"><span>示例程序</span></a></li>
      <li><a href="_xE9_x94_x99_xE8_xAF_xAF_xE7_xA0_x81.html"><span>状态码</span></a></li>
      <li><a href="_xE5_xB8_xB8_xE8_xA7_x81_xE9_x97_xAE_xE9_xA2_x98.html"><span>常见问题</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">InterfaceDemo.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>采集卡的枚举及控制</p>
<p>该示例程序说明如何通过枚举接口枚举自研采集卡，并实现打开采集卡、设置属性等操作。</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;stdio.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;string.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;unistd.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;stdlib.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;pthread.h&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;MvCameraControl.h&quot;</span></div><div class="line"></div><div class="line"><span class="keywordtype">void</span>* g_hInterface = NULL;</div><div class="line"></div><div class="line"><span class="comment">// ch:等待按键输入 | en:Wait for key press</span></div><div class="line"><span class="keywordtype">bool</span> g_bExit = <span class="keyword">false</span>;</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> PressEnterToExit(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">    <span class="keywordtype">int</span> c;</div><div class="line">    <span class="keywordflow">while</span> ( (c = getchar()) != <span class="charliteral">&#39;\n&#39;</span> &amp;&amp; c != EOF );</div><div class="line">    fprintf( stderr, <span class="stringliteral">&quot;\nPress enter to exit.\n&quot;</span>);</div><div class="line">    <span class="keywordflow">while</span>( getchar() != <span class="charliteral">&#39;\n&#39;</span>);</div><div class="line">    g_bExit = <span class="keyword">true</span>;</div><div class="line">    sleep(1);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// ch:打印采集卡信息 | en:Print interface info</span></div><div class="line"><span class="keywordtype">bool</span> PrintInterfaceInfo(<a name="_a0"></a><a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o.html">MV_INTERFACE_INFO</a>* pstInterfaceInfo)</div><div class="line">{</div><div class="line">    <span class="keywordflow">if</span> (NULL == pstInterfaceInfo)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;The Pointer of pstInterfaceInfo is NULL!\n&quot;</span>);</div><div class="line">        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line">    }</div><div class="line">    printf(<span class="stringliteral">&quot;Display name: %s\n&quot;</span>,pstInterfaceInfo-&gt;<a name="a1"></a><a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o.html#ac61840be1627321568c7febe5a2a154c">chDisplayName</a>);</div><div class="line">    printf(<span class="stringliteral">&quot;Serial number: %s\n&quot;</span>,pstInterfaceInfo-&gt;<a name="a2"></a><a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o.html#a11ec0d40110082cc595ad659bfceeeb7">chSerialNumber</a>);</div><div class="line">    printf(<span class="stringliteral">&quot;model name: %s\n&quot;</span>,pstInterfaceInfo-&gt;<a name="a3"></a><a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o.html#a1fd78924df9302fb6421706ddb10c6db">chModelName</a>);</div><div class="line">    printf(<span class="stringliteral">&quot;\n&quot;</span>);</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// ch:设置/获取枚举类型值 | en:Set/Get enum value</span></div><div class="line"><span class="keywordtype">void</span> Set_Get_Enum(<span class="keyword">const</span> <span class="keywordtype">char</span>* str)</div><div class="line">{</div><div class="line">    <a name="_a4"></a><a class="code" href="struct_m_v_c_c___e_n_u_m_v_a_l_u_e.html">MVCC_ENUMVALUE</a> stEnumValue = {0};</div><div class="line">    <a name="_a5"></a><a class="code" href="struct_m_v_c_c___e_n_u_m_e_n_t_r_y.html">MVCC_ENUMENTRY</a> stEnumentryInfo = {0};</div><div class="line"></div><div class="line">    <span class="keywordtype">int</span> nRet = <a name="a6"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga2daf898feb1afa4bd5de232d85a33780">MV_CC_GetEnumValue</a>(g_hInterface,str, &amp;stEnumValue);</div><div class="line">    <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Get %s Fail! nRet [0x%x]\n&quot;</span>, str, nRet);</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">    }</div><div class="line"></div><div class="line">    stEnumentryInfo.<a name="a7"></a><a class="code" href="struct_m_v_c_c___e_n_u_m_e_n_t_r_y.html#a146c4804513ac276ba4d49bcc92979ee">nValue</a> = stEnumValue.<a name="a8"></a><a class="code" href="struct_m_v_c_c___e_n_u_m_v_a_l_u_e.html#a83b19189b7bee89a25ea1f31e96e46e5">nCurValue</a>;</div><div class="line">    nRet = <a name="a9"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga9a96422f32a02418c1f2bbd829425699">MV_CC_GetEnumEntrySymbolic</a>(g_hInterface,str, &amp;stEnumentryInfo);</div><div class="line">    <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Get %s Fail! nRet [0x%x]\n&quot;</span>, str,nRet);</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Get %s = [%s] Success!\n&quot;</span>,str,stEnumentryInfo.<a name="a10"></a><a class="code" href="struct_m_v_c_c___e_n_u_m_e_n_t_r_y.html#ac3a36fac1a4183efe431e6d073e54ec0">chSymbolic</a>);</div><div class="line">    }</div><div class="line"></div><div class="line">    nRet = <a name="a11"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga15a8abe28a1c5a53e10d115c7def4089">MV_CC_SetEnumValue</a>(g_hInterface,str,stEnumValue.<a class="code" href="struct_m_v_c_c___e_n_u_m_v_a_l_u_e.html#a83b19189b7bee89a25ea1f31e96e46e5">nCurValue</a>);</div><div class="line">    <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Set %s Fail! nRet [0x%x]\n&quot;</span>, str,nRet);</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Set %s = [%s] Success!\n&quot;</span>,str,stEnumentryInfo.<a class="code" href="struct_m_v_c_c___e_n_u_m_e_n_t_r_y.html#ac3a36fac1a4183efe431e6d073e54ec0">chSymbolic</a>);</div><div class="line">    }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// ch:设置/获取bool类型值 | en:Set/Get bool value</span></div><div class="line"><span class="keywordtype">void</span> Set_Get_Bool(<span class="keyword">const</span> <span class="keywordtype">char</span>* str)</div><div class="line">{</div><div class="line">    <span class="keywordtype">bool</span> bValue = <span class="keyword">false</span>;</div><div class="line">    <span class="keywordtype">int</span> nRet = <a name="a12"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga23ceabb8e0caf522ae7f77ad8c14cd84">MV_CC_GetBoolValue</a>(g_hInterface,str, &amp;bValue);</div><div class="line">    <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Get %s Fail! nRet [0x%x]\n&quot;</span>, str,nRet);</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Get %s =  [%d] Success!\n&quot;</span>,str,bValue);</div><div class="line">    }</div><div class="line"></div><div class="line">    nRet = <a name="a13"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#gad725e29bc56fa0eb57dfefb4d8d6ea69">MV_CC_SetBoolValue</a>(g_hInterface,str, bValue);</div><div class="line">    <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Set %s Fail! nRet [0x%x]\n&quot;</span>, str,nRet);</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Set %s = [%d] Success!\n&quot;</span>,str,bValue);</div><div class="line">    }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// ch:设置/获取整数类型值 | en:Set/Get int value</span></div><div class="line"><span class="keywordtype">void</span> Set_Get_Int(<span class="keyword">const</span> <span class="keywordtype">char</span>* str)</div><div class="line">{</div><div class="line">    <a name="_a14"></a><a class="code" href="struct_m_v_c_c___i_n_t_v_a_l_u_e___e_x.html">MVCC_INTVALUE_EX</a> stIntValue;</div><div class="line">    <span class="keywordtype">int</span> nRet = <a name="a15"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga6240aac97e206f77b4ce3bd7a1ef1048">MV_CC_GetIntValueEx</a>(g_hInterface,str,&amp;stIntValue);</div><div class="line">    <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Get %s Fail! nRet [0x%x]\n&quot;</span>, str,nRet);</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Get %s =  [%d] Success!\n&quot;</span>,str,stIntValue.<a name="a16"></a><a class="code" href="struct_m_v_c_c___i_n_t_v_a_l_u_e___e_x.html#a75858d445833ad0bbe60edfa610f7f7b">nCurValue</a>);</div><div class="line">    }</div><div class="line">    </div><div class="line">    nRet = <a name="a17"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga9bf0ac21078791974fd4f5b8b2c6328b">MV_CC_SetIntValueEx</a>(g_hInterface,str,stIntValue.<a class="code" href="struct_m_v_c_c___i_n_t_v_a_l_u_e___e_x.html#a75858d445833ad0bbe60edfa610f7f7b">nCurValue</a>);</div><div class="line">    <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Set %s Fail! nRet [0x%x]\n&quot;</span>, str,nRet);</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Set %s = [%d] Success!\n&quot;</span>,str,stIntValue.<a class="code" href="struct_m_v_c_c___i_n_t_v_a_l_u_e___e_x.html#a75858d445833ad0bbe60edfa610f7f7b">nCurValue</a>);</div><div class="line">    }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// ch:设置/获取字符串类型值 | en:Set/Get string value</span></div><div class="line"><span class="keywordtype">void</span> Set_Get_String(<span class="keyword">const</span> <span class="keywordtype">char</span>* str)</div><div class="line">{</div><div class="line">    <a name="_a18"></a><a class="code" href="struct_m_v_c_c___s_t_r_i_n_g_v_a_l_u_e.html">MVCC_STRINGVALUE</a> StringValue;</div><div class="line">    <span class="keywordtype">int</span> nRet = <a name="a19"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga590e5271c688137ea03ab316f2ca2307">MV_CC_GetStringValue</a>(g_hInterface,str, &amp;StringValue);</div><div class="line">    <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Get %s Fail! nRet [0x%x]\n&quot;</span>, str,nRet);</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Get %s =  [%s] Success!\n&quot;</span>,str,StringValue.<a name="a20"></a><a class="code" href="struct_m_v_c_c___s_t_r_i_n_g_v_a_l_u_e.html#af0fd08750070e7f2dbba7e89cf4718e4">chCurValue</a>);</div><div class="line">    }</div><div class="line"></div><div class="line">    nRet = <a name="a21"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga3c816d281b3941584a8fa8ebf14feda1">MV_CC_SetStringValue</a>(g_hInterface,str, StringValue.<a class="code" href="struct_m_v_c_c___s_t_r_i_n_g_v_a_l_u_e.html#af0fd08750070e7f2dbba7e89cf4718e4">chCurValue</a>);</div><div class="line">    <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Set %s Fail! nRet [0x%x]\n&quot;</span>, str,nRet);</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Set %s = [%s] Success!\n&quot;</span>,str,StringValue.<a class="code" href="struct_m_v_c_c___s_t_r_i_n_g_v_a_l_u_e.html#af0fd08750070e7f2dbba7e89cf4718e4">chCurValue</a>);</div><div class="line">    }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">// ch:设置/获取浮点数类型值 | en:Set/Get float value</span></div><div class="line"><span class="keywordtype">void</span> Set_Get_Float(<span class="keyword">const</span> <span class="keywordtype">char</span>* str)</div><div class="line">{</div><div class="line">    <a name="_a22"></a><a class="code" href="struct_m_v_c_c___f_l_o_a_t_v_a_l_u_e.html">MVCC_FLOATVALUE</a> FloatValue;</div><div class="line">    <span class="keywordtype">int</span> nRet = <a name="a23"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#ga480e49d645f1638ce17da841ac72632c">MV_CC_GetFloatValue</a>(g_hInterface,str, &amp;FloatValue);</div><div class="line">    <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Get %s Fail! nRet [0x%x]\n&quot;</span>, str,nRet);</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Get %s =  [%f] Success!\n&quot;</span>,str,FloatValue.<a name="a24"></a><a class="code" href="struct_m_v_c_c___f_l_o_a_t_v_a_l_u_e.html#a11e278521f1696dee14451558c04673a">fCurValue</a>);</div><div class="line">    }</div><div class="line"></div><div class="line">    nRet = <a name="a25"></a><a class="code" href="group___xE5_xB1_x9E_xE6_x80_xA7_xE9_x85_x8D_xE7_xBD_xAE.html#gad43ad99b3a3a0ec2e91f6ad1ad4e99ac">MV_CC_SetFloatValue</a>(g_hInterface,str, FloatValue.<a class="code" href="struct_m_v_c_c___f_l_o_a_t_v_a_l_u_e.html#a11e278521f1696dee14451558c04673a">fCurValue</a>);</div><div class="line">    <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Set %s Fail! nRet [0x%x]\n&quot;</span>, str,nRet);</div><div class="line">        <span class="keywordflow">return</span>;</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">        printf(<span class="stringliteral">&quot;Set %s = [%f] Success!\n&quot;</span>,str,FloatValue.<a class="code" href="struct_m_v_c_c___f_l_o_a_t_v_a_l_u_e.html#a11e278521f1696dee14451558c04673a">fCurValue</a>);</div><div class="line">    }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">//ch:用户输入转为传输层类型 | en:Convert user select to TLayerType</span></div><div class="line"><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> UserSelect2TLayerType(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nSelect)</div><div class="line">{</div><div class="line">    <span class="keywordflow">switch</span>(nSelect)</div><div class="line">    {</div><div class="line">    <span class="keywordflow">case</span> 0:</div><div class="line">            <span class="keywordflow">return</span> <a name="a26"></a><a class="code" href="group___xE5_xAE_x8F_xE5_xAE_x9A_xE4_xB9_x89.html#ga7809501c69b2254b8ce93ffc32f94e89">MV_GIGE_INTERFACE</a>;</div><div class="line">    <span class="keywordflow">case</span> 1:</div><div class="line">            <span class="keywordflow">return</span> <a name="a27"></a><a class="code" href="group___xE5_xAE_x8F_xE5_xAE_x9A_xE4_xB9_x89.html#gae5a9d1153a3bd9fee9c10e8bfa0494d7">MV_CAMERALINK_INTERFACE</a>;</div><div class="line">    <span class="keywordflow">case</span> 2:</div><div class="line">            <span class="keywordflow">return</span> <a name="a28"></a><a class="code" href="group___xE5_xAE_x8F_xE5_xAE_x9A_xE4_xB9_x89.html#gad543da4ccf34413876d6b3bb9d6b782b">MV_CXP_INTERFACE</a>;</div><div class="line">    <span class="keywordflow">case</span> 3:</div><div class="line">            <span class="keywordflow">return</span> <a name="a29"></a><a class="code" href="group___xE5_xAE_x8F_xE5_xAE_x9A_xE4_xB9_x89.html#ga6e18f60e6718031ba00fa3be2abcecf3">MV_XOF_INTERFACE</a>;</div><div class="line">    <span class="keywordflow">default</span>:</div><div class="line">            <span class="keywordflow">return</span> -1;</div><div class="line">    }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line">    <span class="keywordtype">int</span> nRet = MV_OK;</div><div class="line"></div><div class="line">    printf(<span class="stringliteral">&quot;[0]: GIGE Interface\n&quot;</span>);</div><div class="line">    printf(<span class="stringliteral">&quot;[1]: CAMERALINK Interface\n&quot;</span>);</div><div class="line">    printf(<span class="stringliteral">&quot;[2]: CXP Interface\n&quot;</span>);</div><div class="line">    printf(<span class="stringliteral">&quot;[3]: XOF Interface\n\n&quot;</span>);</div><div class="line"></div><div class="line">    <span class="keywordflow">do</span> </div><div class="line">    {</div><div class="line">        <span class="comment">// ch:初始化SDK | en:Initialize SDK</span></div><div class="line">        nRet = <a name="a30"></a><a class="code" href="group___s_d_k_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#ga768544eb6e6435313dd99ee9cf92d59d">MV_CC_Initialize</a>();</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Initialize SDK fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <a name="_a31"></a><a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o___l_i_s_t.html">MV_INTERFACE_INFO_LIST</a> stInterfaceInfoList={0};</div><div class="line"></div><div class="line">        <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nType = 0;</div><div class="line">        printf(<span class="stringliteral">&quot;Please Input Enum Interfaces Type(0-%d):&quot;</span>, 3);</div><div class="line">        scanf(<span class="stringliteral">&quot;%d&quot;</span>, &amp;nType);</div><div class="line"></div><div class="line">        <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nTLayerType = UserSelect2TLayerType(nType);</div><div class="line">        <span class="keywordflow">if</span>(-1 == nTLayerType)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Input error!\n&quot;</span>);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">//ch:枚举采集卡 | en:Enum Interfaces</span></div><div class="line">        nRet = <a name="a32"></a><a class="code" href="group___xE9_x87_x87_xE9_x9B_x86_xE5_x8D_xA1_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#gad22fcad93034b5de199bc8a6c7c1f7eb">MV_CC_EnumInterfaces</a>(nTLayerType, &amp;stInterfaceInfoList);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK != nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Enum Interfaces fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line">        </div><div class="line">        <span class="keywordflow">if</span> (stInterfaceInfoList.<a name="a33"></a><a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o___l_i_s_t.html#aa58fbca6f1f1b5cbed1f4eaaf92dbb95">nInterfaceNum</a> &gt; 0)</div><div class="line">        {</div><div class="line">            <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i &lt; stInterfaceInfoList.<a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o___l_i_s_t.html#aa58fbca6f1f1b5cbed1f4eaaf92dbb95">nInterfaceNum</a>; i++)</div><div class="line">            {</div><div class="line">                printf(<span class="stringliteral">&quot;[Interface %d]:\n&quot;</span>, i);</div><div class="line">                <a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o.html">MV_INTERFACE_INFO</a>* pstInterfaceInfo = stInterfaceInfoList.<a name="a34"></a><a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o___l_i_s_t.html#afa9168d7cfac51ba8585a7407c2f2648">pInterfaceInfos</a>[i];</div><div class="line">                <span class="keywordflow">if</span> (NULL == pstInterfaceInfo)</div><div class="line">                {</div><div class="line">                    <span class="keywordflow">break</span>;</div><div class="line">                } </div><div class="line">                PrintInterfaceInfo(pstInterfaceInfo);            </div><div class="line">            }</div><div class="line">            printf(<span class="stringliteral">&quot;Enum Interfaces success!\n\n&quot;</span>);</div><div class="line">        } </div><div class="line">        <span class="keywordflow">else</span></div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Find No Interface!\n&quot;</span>);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        printf(<span class="stringliteral">&quot;Please Input Interfaces index(0-%d):&quot;</span>, stInterfaceInfoList.<a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o___l_i_s_t.html#aa58fbca6f1f1b5cbed1f4eaaf92dbb95">nInterfaceNum</a>-1);</div><div class="line">        <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nIndex = 0;</div><div class="line">        scanf(<span class="stringliteral">&quot;%d&quot;</span>, &amp;nIndex);</div><div class="line"></div><div class="line">        <span class="keywordflow">if</span> (nIndex &gt;= stInterfaceInfoList.<a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o___l_i_s_t.html#aa58fbca6f1f1b5cbed1f4eaaf92dbb95">nInterfaceNum</a>)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Input error!\n&quot;</span>);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">//ch:创建采集卡句柄 | en:Create interface handle</span></div><div class="line">        nRet = <a name="a35"></a><a class="code" href="group___xE9_x87_x87_xE9_x9B_x86_xE5_x8D_xA1_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#ga62d20dad6ddb396018fe82ef5e676bb1">MV_CC_CreateInterface</a>(&amp;g_hInterface, stInterfaceInfoList.<a class="code" href="struct_m_v___i_n_t_e_r_f_a_c_e___i_n_f_o___l_i_s_t.html#afa9168d7cfac51ba8585a7407c2f2648">pInterfaceInfos</a>[nIndex]);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK == nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Create Interface success!\n&quot;</span>);</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span></div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Create Interface Handle fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">//ch:打开采集卡 | en:Open interface</span></div><div class="line">        nRet = <a name="a36"></a><a class="code" href="group___xE9_x87_x87_xE9_x9B_x86_xE5_x8D_xA1_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#gac57264660ca9acb36a43c23adb2147a7">MV_CC_OpenInterface</a>(g_hInterface, <span class="stringliteral">&quot;这块暂时随便传入一个非空指针即可&quot;</span>);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK == nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Open Interface success!\n&quot;</span>);</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span></div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Open Interface fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">//ch:采集卡属性操作,不同类型卡对各自常用属性进行获取和设置</span></div><div class="line">        <span class="comment">//en:Interface feature operation, get/set each common feature for different interface</span></div><div class="line">        <span class="keywordflow">switch</span>(nType)</div><div class="line">        {</div><div class="line">        <span class="keywordflow">case</span> 0:</div><div class="line">            {</div><div class="line">                <span class="comment">//ch:MV_GIGE_INTERFACE卡属性获取和设置操作 | en:Get/Set feature for MV_GIGE_INTERFACE</span></div><div class="line">                Set_Get_Enum(<span class="stringliteral">&quot;StreamSelector&quot;</span>);</div><div class="line">                Set_Get_Enum(<span class="stringliteral">&quot;TimerSelector&quot;</span>);</div><div class="line">                Set_Get_Enum(<span class="stringliteral">&quot;TimerTriggerSource&quot;</span>);</div><div class="line">                Set_Get_Enum(<span class="stringliteral">&quot;TimerTriggerActivation&quot;</span>);</div><div class="line">                Set_Get_Bool(<span class="stringliteral">&quot;HBDecompression&quot;</span>);</div><div class="line">                Set_Get_Int(<span class="stringliteral">&quot;TimerDuration&quot;</span>);</div><div class="line">                Set_Get_Int(<span class="stringliteral">&quot;TimerDelay&quot;</span>);</div><div class="line">                Set_Get_Int(<span class="stringliteral">&quot;TimerFrequency&quot;</span>);</div><div class="line">                <span class="keywordflow">break</span>;</div><div class="line">            }</div><div class="line">        <span class="keywordflow">case</span> 1:</div><div class="line">            {</div><div class="line">                <span class="comment">//ch:MV_CAMERALINK_INTERFACE卡属性操作 | en:Get/Set feature for MV_CAMERALINK_INTERFACE</span></div><div class="line">                Set_Get_Enum(<span class="stringliteral">&quot;StreamSelector&quot;</span>);</div><div class="line">                Set_Get_Enum(<span class="stringliteral">&quot;CameraType&quot;</span>);</div><div class="line">                Set_Get_Enum(<span class="stringliteral">&quot;StreamPartialImageControl&quot;</span>);</div><div class="line">                Set_Get_Int(<span class="stringliteral">&quot;ImageHeight&quot;</span>);</div><div class="line">                Set_Get_Int(<span class="stringliteral">&quot;FrameTimeoutTime&quot;</span>);</div><div class="line">                <span class="keywordflow">break</span>;</div><div class="line">            }</div><div class="line">        <span class="keywordflow">case</span> 2:</div><div class="line">            {</div><div class="line">                <span class="comment">//ch:MV_CXP_INTERFACE卡属性操作 | en:Get/Set feature for MV_CXP_INTERFACE</span></div><div class="line">                Set_Get_Enum(<span class="stringliteral">&quot;StreamSelector&quot;</span>);</div><div class="line">                Set_Get_String(<span class="stringliteral">&quot;CurrentStreamDevice&quot;</span>);</div><div class="line">                Set_Get_Int(<span class="stringliteral">&quot;StreamEnableStatus&quot;</span>);</div><div class="line">                Set_Get_Bool(<span class="stringliteral">&quot;BayerCFAEnable&quot;</span>);</div><div class="line">                Set_Get_Bool(<span class="stringliteral">&quot;IspGammaEnable&quot;</span>);</div><div class="line">                Set_Get_Float(<span class="stringliteral">&quot;IspGamma&quot;</span>);</div><div class="line">                <span class="keywordflow">break</span>;</div><div class="line">            }</div><div class="line">        <span class="keywordflow">case</span> 3:</div><div class="line">            {</div><div class="line">                <span class="comment">//ch:MV_XOF_INTERFACE卡属性操作 | en:Get/Set feature for MV_XOF_INTERFACE</span></div><div class="line">                Set_Get_Enum(<span class="stringliteral">&quot;StreamSelector&quot;</span>);</div><div class="line">                Set_Get_String(<span class="stringliteral">&quot;CurrentStreamDevice&quot;</span>);</div><div class="line">                Set_Get_Int(<span class="stringliteral">&quot;StreamEnableStatus&quot;</span>);</div><div class="line">                Set_Get_Bool(<span class="stringliteral">&quot;BayerCFAEnable&quot;</span>);</div><div class="line">                Set_Get_Bool(<span class="stringliteral">&quot;IspGammaEnable&quot;</span>);</div><div class="line">                Set_Get_Float(<span class="stringliteral">&quot;IspGamma&quot;</span>);</div><div class="line">                <span class="keywordflow">break</span>;</div><div class="line">            }</div><div class="line">        <span class="keywordflow">default</span>:</div><div class="line">            {</div><div class="line">                printf(<span class="stringliteral">&quot;Input error!\n&quot;</span>);</div><div class="line">                <span class="keywordflow">break</span>;</div><div class="line">            }</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">//ch:关闭采集卡 | en:Close interface</span></div><div class="line">        nRet = <a name="a37"></a><a class="code" href="group___xE9_x87_x87_xE9_x9B_x86_xE5_x8D_xA1_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#ga98f4a5025eebf615499a23da0b73970d">MV_CC_CloseInterface</a>(g_hInterface);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK == nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Close Interface success!\n&quot;</span>);</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span></div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Close Interface Handle fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line"></div><div class="line">        <span class="comment">//ch:销毁采集卡句柄 | en:Destroy interface handle</span></div><div class="line">        nRet = <a name="a38"></a><a class="code" href="group___xE9_x87_x87_xE9_x9B_x86_xE5_x8D_xA1_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#ga365d684482405b74afe9d21b986185af">MV_CC_DestroyInterface</a>(g_hInterface);</div><div class="line">        <span class="keywordflow">if</span> (MV_OK == nRet)</div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Destroy Interface success!\n&quot;</span>);</div><div class="line">        }</div><div class="line">        <span class="keywordflow">else</span></div><div class="line">        {</div><div class="line">            printf(<span class="stringliteral">&quot;Destroy Interface Handle fail! nRet [0x%x]\n&quot;</span>, nRet);</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line">        }</div><div class="line">        g_hInterface = NULL;</div><div class="line">    } <span class="keywordflow">while</span> (0);</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (g_hInterface != NULL)</div><div class="line">    {</div><div class="line">        <a class="code" href="group___xE9_x87_x87_xE9_x9B_x86_xE5_x8D_xA1_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#ga365d684482405b74afe9d21b986185af">MV_CC_DestroyInterface</a>(g_hInterface);</div><div class="line">        g_hInterface = NULL;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">// ch:反初始化SDK | en:Finalize SDK</span></div><div class="line">    <a name="a39"></a><a class="code" href="group___s_d_k_xE5_x88_x9D_xE5_xA7_x8B_xE5_x8C_x96.html#gafa1820a0da8671fc6f77dc9a7dfa69d3">MV_CC_Finalize</a>();</div><div class="line"></div><div class="line">    printf(<span class="stringliteral">&quot;exit\n&quot;</span>);</div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
<!-- start footer part -->
<div class="footer" style="text-align: right;">
	<hr/>
	<small></small>
</div>
<script>
	// 当前选中的菜单
	var currentMenuItem = document.querySelector('.tablist > li.current > a')
	if (currentMenuItem) { // 子菜单情况
	  window.parent.postMessage({
		navHref: currentMenuItem.href
	  }, '*')
	} else {
	  window.parent.postMessage({
		url: window.location.href
	  }, '*')
	}
  </script>
</body>
</html>